package utils.qrcode
{
	
	public class QrCodeStrings
	{
		public function QrCodeStrings()
		{
		}
		
		public static function getWifiString(ssid:String, keyType:String, key:String):String{
			return "WIFI:T:"+keyType+";S:"+ssid+";p:"+key; 
		}
		
		public static function getEmailString(email:String, subj:String="", text:String="", kodieren:Boolean=true):String{
			subj = subj.replace(" ","%20");
			text = text.replace(" ","%20");
			var qrCodeString:String = "mailto:"+email+"?subject="+subj+"%26body="+text;
			if(kodieren){
				qrCodeString = urlUmlaut(qrCodeString);
			}
			return qrCodeString
		}
		
//		public static function getVCardString(emp:EmployeeVO, kodieren:Boolean=true):String{
//			var qrCodeString:String = 	"BEGIN:VCARD%0AVERSION:2.1";
//			qrCodeString 	+=	"%0AN:"+emp.lastName+";"+emp.firstName;
//			qrCodeString	+=	"%0AFN:"+emp.firstName + " "+ emp.lastName;
//			if (emp.title != null)
//				qrCodeString	+=	"%0ATITLE:"+emp.title;
//			if (emp.company != null)
//				qrCodeString	+=	"%0AORG:"+emp.company;
//			if (emp.mobile != null)
//				qrCodeString	+=	"%0ATEL;CELL:"+emp.mobile;
//			if (emp.phone != null)
//				qrCodeString	+=	"%0ATEL;WORK:"+emp.phone;
//			if (emp.email != null)
//				qrCodeString	+= 	"%0AEMAIL;WORK;INTERNET:"+emp.email;
//			if (emp.url != null)
//				qrCodeString    +=  "%0AURL;WORK;:"+emp.url;
//			if (emp.street != null)
//				qrCodeString	+=	"%0AADR;WORK:;;"+emp.street+";"+emp.city+";;"+emp.postalCode+";Deutschland";
//			qrCodeString	+=	"%0AEND:VCARD";
//			
//			if(kodieren){
//				qrCodeString = urlUmlaut(qrCodeString);
//			}
//			return qrCodeString;
//		}
//		
//		public static function getTelString(emp:EmployeeVO, kodieren:Boolean = true):String{
//			
//			var qrCodeString:String = "TEL:"+emp.mobile;
//			if(kodieren){
//				qrCodeString = urlUmlaut(qrCodeString);
//			}
//			return qrCodeString;
//		}
//		
//		public static function getCallString(number:String, kodieren:Boolean = true):String{
//			
//			var qrCodeString:String = "TEL:"+number;
//			if(kodieren){
//				qrCodeString = urlUmlaut(qrCodeString);
//			}
//			return qrCodeString;
//		}
//		
//		public static function getSmsString(emp:EmployeeVO, kodieren:Boolean=true):String{
//			var qrCodeString:String = "SMSTO:"+emp.mobile+"%3A"+"Sehr geehrte(r) Herr/Frau "+emp.lastName;
//			if(kodieren){
//				qrCodeString = urlUmlaut(qrCodeString);
//			}
//			return qrCodeString;
//		}
		
		
		
		
		public static function urlUmlaut(eingabetext:String):String {
			//Sonderzeichen umwandeln
			var sonderzeichensuchen:Array=new Array("%2B");
			//var sonderzeichensuchen:Array=new Array("%2B","%E4","%C4","%F6","%D6","%FC","%DC");
			var sonderzeichenersetzen:Array=new Array("+");
			//var sonderzeichenersetzen:Array=new Array("+","ä","Ä","ö","Ö","ü","Ü");
			var newString:String = eingabetext;
			for (var i:Number = 0; i < sonderzeichensuchen.length; i++) {
				while(newString.indexOf(sonderzeichenersetzen[i]) > -1){
					newString = newString.replace(sonderzeichenersetzen[i],sonderzeichensuchen[i]);   
				}
			}
			return newString;
		}
		
	}
}